package com.company.java.basic.day05;

import java.util.Scanner;

public class Day05_Test {
    public static void main(String[] args) {
        //1、输入人数和成绩，并排序
        /*
        //输入
        Scanner input = new Scanner(System.in);
        System.out.print("请输入总人数：");
        int numb = input.nextInt();
        //定义数组
        int[] score = new int[numb];
        for(int i=0;i<numb;i++){
            System.out.print("请输入成绩：");
            score[i] = input.nextInt();
        }
        //冒泡排序
        for (int i =1;i<score.length;i++){
            for (int j=0;j<score.length-i;j++){
                if (score[j]<score[j+1]){
                    score[j] = score[j] + score[j+1];
                    score[j+1] = score[j] - score[j+1];
                    score[j] = score[j] - score[j+1];
                }
            }
        }
        //快速排序
        int max = 0;
        for (int i =1;i<score.length;i++){
            for (int j=1;j<score.length-i;j++){
                if (score[max]<score[j]){
                    max = j;
                }
                if(max!=j){
                score[max] = score[j] + score[max];
                score[j] = score[max] - score[j];
                score[max] = score[max] - score[j];
                }

            }
        for (int i =0;i<score.length;i++){
            System.out.println(score[i]);
        }

         */

        //2、合并数组
        /*
        // 定义并初始化数组
        int[] a = new int[10];
        int[] b = new int[5];
        for (int i=0;i<b.length;i++){
            a[i] = i;
            b[i] = i+5;
        }
        //合并数组
        for (int i=0;i<b.length;i++){
            a[b.length+i] = b[i];
        }
        //打印合并后的数组
        for (int i=0;i<a.length;i++){
            System.out.print(a[i]);
        }

         */

        //3、杨辉三角
        /*
        int[][] a = new int[10][];
        a[0] = new int[1];
        a[0][0] = 1;
        System.out.println(a[0][0]);
        for (int i=1;i<a.length;i++){
            a[i] = new int[i+1];
            for (int j=0;j<a[i].length;j++){
                if (j==0 || j==i){
                    a[i][j]=1;
                }else {
                    a[i][j] = a[i-1][j-1]+a[i-1][j];
                }
                System.out.print(a[i][j]+" ");
            }
            System.out.println();
        }

         */

        //4、打印扑克牌
        /*
        //定义数组
        String[][] a = new String[2][];
        a[0] = new String[]{"黑桃","红桃","梅花","方块"};
        a[1] = new String[]{"A","2","3","4","5","6","7","8","9","10",
                "J","Q","K"};

        for (int i=0;i<a[0].length;i++){
            for (int j=0;j<a[1].length;j++){
                System.out.print(a[0][i]+a[1][j]+" ");
            }
            System.out.println();
        }

         */

        //5、统计成绩
        /*
        //1、输入组数、每组人数
        Scanner input = new Scanner(System.in);
        System.out.print("输入如组数：");
        int groups = input.nextInt();
        int[][] class_num = new int[groups][];
        for (int i=0;i<class_num.length;i++){
            System.out.print("输入第"+(i+1)+"组数人数：");
            int people = input.nextInt();
            class_num[i] = new int[people];
        }
        // 输入每组成绩
        for (int i=0;i<class_num.length;i++){
            for (int j=0;j<class_num[i].length;j++){
                System.out.print("第"+(i+1)+"组第"+(j+1)+"个人的成绩：");
                int score = input.nextInt();
                class_num[i][j] = score;
            }
        }
        // 统计每组平均分、最高最低分
        for (int i=0;i<class_num.length;i++){
            int group_max = 0;
            int group_min = 0;
            int sum = class_num[i][0];
            for (int j=1;j<class_num[i].length;j++){
                if (class_num[i][group_max]<class_num[i][j]){
                    group_max = j;
                }
                if (class_num[i][group_min]>class_num[i][j]){
                    group_min = j;
                }
                sum += class_num[i][j];
            }
            System.out.println("第"+(i+1)+"组最高成绩："+class_num[i][group_max]+"\t"+
                    "最低成绩："+class_num[i][group_min]+"\t"+"平均值："+(sum/class_num[i].length));
        }
        int class_max = 0;
        int class_min = class_num[0][0];
        int class_sum = 0;
        int class_all = 0;
        for (int i=0;i<class_num.length;i++){
            class_sum += class_num[i][0];
            for (int j=0;j<class_num[i].length;j++){
                if (class_max<class_num[i][j]){
                    class_max = class_num[i][j];
                }
                if (class_min>class_num[i][j]){
                    class_min = class_num[i][j];
                }
                class_sum += class_num[i][j];
                class_all++;
            }
        }
        System.out.println("全班最高分："+class_max);
        System.out.println("全班最低分："+class_min);
        System.out.println("全班平均分："+(class_sum/class_all));
        System.out.println("全班总人数："+class_all);

         */

    }
}
